{template header}
<style>
.sHistory {behavior:url(#default#savehistory);}
</style>
<div class="cru">
	<a href="{SITE_URL}">{$setting['site_name']}</a>
	<!--{loop $navlist $nav}-->
		 &gt;&gt; <a href="{url category/view/$nav['id']}">{$nav['name']}</a>  
	<!--{/loop}-->	
</div>

<div class="listBody">
	<div class="block">
    	<div class="title"><h3>&nbsp;待解决问题</h3></div>
        <div class="question">
        	<div class="head">
                <h5>{$question['title']}</h5>
                <div class="operaBtns">
					<div>
						<ul>
						<li><a href="javascript:window.open('http://share.renren.com/share/buttonshare.do?title='+encodeURIComponent(document.title.substring(0,76))+'&link='+encodeURIComponent(location.href)+'&content=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0" style="color:#000000;text-decoration:none;font-size:12px;font-weight:normal"><SPAN style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 1px; CURSOR: pointer; PADDING-TOP: 0px"><IMG alt=人人网 src="http://s.xnimg.cn/favicon-rr.ico" align=absMiddle border=0>&nbsp;人人网</SPAN></a> </li>
						<li><a href="javascript:window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title.substring(0,76))+'&url='+encodeURIComponent(location.href)+'&rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0" style="color:#000000;text-decoration:none;font-size:12px;font-weight:normal"><SPAN style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 1px; CURSOR: pointer; PADDING-TOP: 0px"><IMG alt=新浪微博 src="http://t.sina.com.cn/favicon.ico" align=absMiddle border=0>&nbsp;新浪微博</SPAN></a></li>
						<li><a href="javascript:window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(document.title.substring(0,76))+'&rurl='+encodeURIComponent(location.href)+'&rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0" style="color:#000000;text-decoration:none;font-size:12px;font-weight:normal"><SPAN style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; FONT-SIZE: 12px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 1px; CURSOR: pointer; PADDING-TOP: 0px"><IMG alt=开心网 src="http://img1.kaixin001.com.cn/i/favicon.ico" align=absMiddle border=0>&nbsp;开心网</SPAN></a></li>
						<li>分享到：</li>
						</ul>
					</div>
                </div>
            </div>
            <div class="cont">{$question['description']}</div>
            <div class="askInfo">
            	提问者:	<!--{if $question['hidden']}-->匿名<!--{else}--><a href="{url user/space/$question['authorid']}" target="_blank">{$question['author']}</a><!--{/if}-->&nbsp;&nbsp;
            	悬赏分:<span class="score">{$question['price']}分</span>
            	提问时间:{$asktime}&nbsp;
            	距离结束:<font id="LiveClock1">{$endtime}</font>
            </div>
            <!--{if $supplylist}-->
            <div class="questionSupply">
            	<h5>对问题的补充</h5>
            	<!--{loop $supplylist $supply}-->
            	<div>{$supply['content']}</div>
            	<p>补充时间:{$supply['format_time']}</p>
            	<!--{/loop}-->
            </div>
			<!--{/if}-->
			
           <!-- 处理问题开始 --> 
		  <div style="display:none" class="containerBg guide" id="usropt"> 
            	<div class="head"> 
                	<h5>处理问题</h5> 
                </div> 
              <div class="cont"> 
              	<p>如果已获得满意的回答，请及时采纳，感谢回答者。若还没有满意的回答，可以尝试以下操作：</p> 
                <ul> 
                	<li><input class="btn" type="button" value="问题补充" name="btnsupply" onclick="mysupply();">&nbsp;可以对您的提问补充细节，以得到更准确的答案;</li> 
                	<li><input class="btn" type="button" value="提高悬赏" name="btnaddscore" onclick="addscore();">&nbsp; 提高悬赏分，以提高问题的关注度，并获得额外5天问题有效期;</li>
                	<!--{if $question['answers']>1}-->
                	<li>
	                	<form name="govoteForm" action="index.php?c=question&a=govote" method="post">
	                	<input type="hidden" value="{$question['id']}" name="qid">
	                	<input class="btn" type="submit" value="发起投票" name="submit">&nbsp;不知道哪个回答最好时，可让网友投票来选出最佳答案;
	                	</form>
                	</li>
                	<!--{/if}-->
                	<li>	
                	<form name="closeForm" action="index.php?c=question&a=close" method="post">
							<input type="hidden" value="{$question['id']}" name="qid">
							<input class="btn" type="submit" value="结束问题" name="submit">&nbsp;没有满意的回答，还可直接结束提问，关闭问题
					</form>
					</li> 
                </ul> 
              </div> 
          </div> 
          <!--{if $ad}-->
          <div id="ad" class="adv">
          <p>{$ad['code']}</p>
          </div>
          <!--{/if}-->
            <!-- 处理问题结束 --> 

			<!-- 回答该问题 -->
			<div style="display:none" id="asropt" class="containerBg">
				<div class="insertForm">
				<form  name="answerForm"  action="index.php?c=question&a=answer" method="post">
                	<div class="head"><h5>我来回答：</h5><a name="a_reply_topic"></a></div>
                    <div class="formItem">
						<p>
                        	<textarea id="mycontent" name="content"  rows="15" cols="80" style="color: rgb(153, 153, 153);"   ></textarea>
                        </p>
      
                        <!--{if $setting['code_ask']}-->
                     	<p>验证码 ：<input maxlength="4" name="code" size="10" />&nbsp;&nbsp;<img id="verifycode" onclick="javascript:updatecode();" src="index.php?c=user&a=code"/>&nbsp;<span id="codetip"><a href="javascript:updatecode();">看不清，换一个</a></span></p><br />
                     	<!--{/if}-->
                     	
                        <p>
                          <input type="hidden" value="{$question['id']}" name="qid">
                          <input type="hidden" value="{$question['title']}" name="title">
                          <input type="button" class="btn"  value="提交回答" name="mybutton"  onClick="mylogin();" >&nbsp;&nbsp;
                        </p>
                        
                    </div>
              	</form>  
				</div>
			</div>
           <!-- 回答问题结束 -->
		</div>
	</div>
 
	<!--{if $question['answers']}-->
	<div class="block">
    	<div class="title">
        	<h3>回答<small>共{$question['answers']}条</small></h3>
        </div>
        <!--{loop $answerlist $index $answer}-->
     	<div class="question otherAsw">
     		<div class="head"><div class="aswInfo" id="asr{$answer['authorid']}" >
				回答人：<a target="_blank" href="{url user/space/$answer['authorid']}">{$answer['author']}</a>&nbsp;
				时间：{$answer['time']}
			</div>
			<div id="apt_{$answer['id']}" style="display:none" class="operaBtns">
			<ul>
				<form method="post" action="index.php?c=question&a=adopt" name="adopt{$answer['id']}">
					<input type="hidden" value="{$answer['qid']}" name="qid"/>
					<input type="hidden" value="{$answer['id']}" name="aid"/>
					<li><input type="submit"  class="btn"  value="采纳为答案" name="submit"/></li>
				</form>
			</ul>
			</div>
			<div id="eaopt{$answer['authorid']}" style="display:none" class="operaBtns">
			<ul>
				<li><input type="button" class="btn" value="修改回答" name="submit" onclick="editanswer({$answer['id']},'mc{$index}');" /></li>
			</ul>
			</div>
	  </div>
	   <div class="cont" id="mc{$index}">{$answer['content']}</div>
	   <!--{/loop}-->
   </div>
   <!--{/if}-->
</div>
</div>

<script charset="utf-8" src="{SITE_URL}js/editor/kindeditor.js"></script>
<script>
	KE.init({
		id : 'mycontent',
		resizeMode : 1,
		allowUpload : false,
		newlineTag : 'br',
		items : [
		'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
		'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
		'insertunorderedlist', '|', 'image', 'link']
	});
</script>
<script type="text/javascript">
	$.getJSON(g_site_url+"index.php?user/ajaxheader/"+Math.random(),function(user){
		g_user=user;	
		if($question['authorid']==user.uid){
			$('#usropt').show();
			$("div[id^='apt']").show();
		}else{
			already=(0!=$('#asr'+user.uid).size());
			if(already){
				$('#eaopt'+user.uid).show();
			}else{
				$('#asropt').show();
				KE.create('mycontent');
			}
		}
	}); 

	function mysupply(){
		$.dialog({
		    id:'supplyDiv',
		    position:'center',
		    align:'left',
		    fixed:1,
		    width:600,
		    title:'补充问题',
		    fnOk:function(){document.supplyForm.submit();$.dialog.close('supplyDiv')},
		    fnCancel:function(){$.dialog.close('supplyDiv')},
		    content:'补充提问细节，以得到更准确的答案。<div><form name="supplyForm"  action="{url question/supply/$question['id']}" method="post" ><textarea id="mysupply" name="content" style="width: 95%; padding-top: 1px; font-size: 14px;" rows="10" ></textarea></form></div>'
		  });
		KE.init({
			id : 'mysupply',
			resizeMode : 1,
			allowUpload : false,
			newlineTag : 'br',
			items : [
			'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'image', 'link']
		});
		KE.create('mysupply');
	}
	
	function addscore(){
		$.dialog({
		    id:'addscoreDiv',
		    position:'center',
		    align:'left',
		    fixed:1,
		    width:300,
		    height:100,
		    title:'追加悬赏',
		    fnOk:function(){document.addscoreForm.submit();$.dialog.close('addscoreDiv')},
		    fnCancel:function(){$.dialog.close('addscoreDiv')},
		    content:'&nbsp;&nbsp;&nbsp;&nbsp;提问期内，追加悬赏一次，可延长问题的有效期3天。<br />&nbsp;&nbsp;&nbsp;&nbsp;当您一次悬赏的财富值高于20分时，该问题将等同于新提出的问题，在所属分类的问题列表中显示为最新。 <div class="b4 bcg mb12"><form name="addscoreForm"  action="{url question/addscore/$question['id']}" method="post" >追加悬赏<select name="score"><option value="5" selected="selected">5</option><option value="10">10</option><option value="15">15</option><option value="20">20</option><option value="30">30</option><option value="40">40</option><option value="50">50</option></select>分</form></div>'
		  });
	}
	
	function editanswer(aid,mcdivid){
	 	var mc_content=$('#'+mcdivid).html();
	 	//mc_content=mc_content.replaceAll("<br>","\n");
		$.dialog({
		    id:'editanswerDiv',
		    position:'center',
		    align:'left',
		    fixed:1,
		    width:600,
		    title:'修改回答',
		    fnOk:function(){document.editanswerForm.submit();$.dialog.close('editanswerDiv')},
		    fnCancel:function(){$.dialog.close('editanswerDiv')},
		    content:g_user.username+',您要修改的回答如下: <div><form name="editanswerForm"  action="index.php?c=question&a=editanswer" method="post" ><textarea id="mc" name="content" style="width: 95%; padding-top: 1px; font-size: 14px;" rows="10" >'+mc_content+'</textarea><input type="hidden"  value="{$question['id']}" name="qid"/><input type="hidden" id="ma" value="'+aid+'" name="aid"/></form></div>'
		  });
		KE.init({
			id : 'mc',
			resizeMode : 1,
			allowUpload : false,
			newlineTag : 'br',
			items : [
			'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'image', 'link']
		});
		KE.create('mc');
	}

	function mylogin(){
		var content=$('#mycontent').val();
		if(bytes(content)<=10){
			alert('回答内容不能少于10个字！');
			return;
		}
	   if(0==g_user.uid){
			$.dialog({
			    id:'loginDiv',
			    position:'center',
			    align:'left',
			    fixed:1,
			    width:300,
			     height:100,
			    title:'提交回答',
			    okText:'登录并提交回答',
			    fnOk:function(){
				    	var username=$('#myusername').val();
				    	var password=$('#mypassword').val();
					     $.ajax({
						   type: "post",
						   url: "index.php?c=user&a=ajaxlogin",
						   data: "username="+username+"&password="+password,
						   success: function(msg){
						     if(1==msg){
						     	$.dialog.close('loginDiv');document.answerForm.submit();
						     }else{
						     	alert('用户名或密码错误！');
						     }
						   }
						}); 
			     },
			    content:'<p /><table cellspacing="0" cellpadding="0" width="70%" border="0" valign="top"><tr><td class="f14" valign="top" nowrap align="left" width="40%" height="35">用户名 :&nbsp;&nbsp; </td><td valign="top" width="60%" height="35"><input maxlength="20" id="myusername" name="username"> </td></tr><tr><td class="f14" valign="top" nowrap align="left" height="35"> 密&nbsp&nbsp码 :&nbsp;&nbsp; </td><td valign="top" height="35"><input id="mypassword" type="password" maxlength="32" name="password"></td></tr></table>'
			  });
		}else{
			document.answerForm.submit();
		}
	}
</script>
{template footer}